package com.smec.moblie.activity;

import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.smec.moblie.R;
import com.smec.moblie.bean.MaintenanceNoticeBean;
import com.smec.moblie.crash.ExitAppUtils;
import com.smec.moblie.util.URLImageGetter;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 广播通知详情
 * Created by sunyubo on 16/2/26.
 */
public class RemesNoticeDetailActivity extends BaseActivity {
    /** 返回按钮 **/
    @BindView(R.id.imageview_back)
    ImageView imageviewBack;
    /** 广播通知标题 **/
    @BindView(R.id.textview_notice_title)
    TextView textview_notice_title;
    /** 广播通知日期 **/
    @BindView(R.id.textview_notice_date)
    TextView textview_notice_date;
    /** 广播通知内容 **/
    @BindView(R.id.textview_notice_content)
    TextView textview_notice_content;
    @BindView(R.id.rl_title)
    RelativeLayout rl_title;

    @Override
    protected void setContentView() {
        setContentView(R.layout.remes_act_remesnoticedetail);
    }

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        ExitAppUtils.getInstance().addActivity(this);

//        PublicControl.setMargins(rl_title, 0, getStatusBarHeight(RemesNoticeDetailActivity.this), 0, 0);
    }

    @Override
    protected void getData() {
        MaintenanceNoticeBean maintenanceNoticeBean = (MaintenanceNoticeBean) getIntent().getSerializableExtra("MaintenanceNoticeBean");
        String noticeParentTitle = maintenanceNoticeBean.getNotice_title();
        if(noticeParentTitle!= null ){
            if(noticeParentTitle.length()>15){
                noticeParentTitle = noticeParentTitle.substring(0, 15).concat("...");
            }
        }

//        textview_noticeParentTitle.setText(noticeParentTitle);
        textview_notice_title.setText(maintenanceNoticeBean.getNotice_title());
        textview_notice_date.setText(maintenanceNoticeBean.getNotice_date());


        //显示html内容
        textview_notice_content.setMovementMethod(LinkMovementMethod.getInstance());//超链接生效
        URLImageGetter ReviewImgGetter = new URLImageGetter(RemesNoticeDetailActivity.this, textview_notice_content);
        textview_notice_content.setText(Html.fromHtml(maintenanceNoticeBean.getNotice_context(), ReviewImgGetter, null));

    }

    @Override
    public void onClick(View v) {

    }

    @OnClick(R.id.imageview_back)
    public void imageview_back() {
        RemesNoticeDetailActivity.this.finish();
    }
}
